// local control sets
forv q = 1/ $qLags {
	local vlist1 `vlist1' c.l`q'_X_TaxcutToGDP
}
di "`vlist1'"

* other macro controls
forv p = 1/$pLags {
	foreach var in $controlist {			
				local vlist2 `vlist2' c.l`p'd_`var'
	}
}
di "`vlist2'"

if missing(`"$controlist"') {
	forv p = 1/$pLags {
		foreach var in $controlist1 {
			local vlist2 `vlist2' c.l`p'_`var'
		}
	}

	forv p = 1/$pLags {
		foreach var in $controlist2 {           		
			local vlist2 `vlist2' c.l`p'd_`var'	
		}
	}
	di "`vlist2'"
}

* add WWII dummy or not
local vlist3 
if $dummyWWII == 1 {
	local vlist3 `vlist3' dummyWWII
	di "`vlist3'"
}

* spending controls
local vlist4

if $spendControl == 1 { 
		if missing("$gLags") {	
		global gLags = $pLags	
	}
	
	forv g = 0/$gLags {
						
			if $gLeads == 0 {
			local vlist4 `vlist4' c.l`g'_${spendControlVar}
			}
			
			if $gLeads == 1 {
			local vlist4 `vlist4' c.f`g'_${spendControlVar}
			}

	}
}
di "`vlist4'"

local hirf = ${hmax} - 1
 
cap drop b Quarters Zero
cap drop u${alpha1} d${alpha1}
cap drop u${alpha2} d${alpha2}
gen Quarters = _n       if _n<= $hmax
gen Zero =  0           if _n<= $hmax
gen b=0
gen v=0
gen u${alpha1}=0
gen d${alpha1}=0
if ${cfbands} == 2 {
	gen u${alpha2}=0
	gen d${alpha2}=0
}
	
if "${LHS}" == "smoothed" {
	forv h = 0/`hirf' {

		${Quiet} regress f`h'${depvar}smooth X_TaxcutToGDP `vlist1' `vlist2' `vlist3' `vlist4', vce(robust)

		replace b = _b[X_TaxcutToGDP]           if _n == `h'+1
		replace v = _se[X_TaxcutToGDP]          if _n == `h'+1
		
		replace u${alpha1} = b + ${zscore1}*v    if _n == `h'+1
		replace d${alpha1} = b - ${zscore1}*v    if _n == `h'+1

		if ${cfbands} == 2 {
			replace u${alpha2} = b + ${zscore2}*v    if _n == `h'+1
			replace d${alpha2} = b - ${zscore2}*v    if _n == `h'+1
		}
	}

}

else if "${LHS}" == "raw" {
	forv h = 0/`hirf' {

		 ${Quiet} regress ${depvar}`h' X_TaxcutToGDP `vlist1' `vlist2' `vlist3' `vlist4', vce(robust)
			
		replace b = _b[X_TaxcutToGDP]      if _n == `h'+1
		replace v = _se[X_TaxcutToGDP]     if _n == `h'+1
		
		replace u${alpha1} = b + ${zscore1}*v    if _n == `h'+1
		replace d${alpha1} = b - ${zscore1}*v    if _n == `h'+1

		if ${cfbands} == 2 {
			replace u${alpha2} = b + ${zscore2}*v    if _n == `h'+1
			replace d${alpha2} = b - ${zscore2}*v    if _n == `h'+1
		}
	}

}

	if ${PlotIRF} == 1 {
		do ${dofilepath}/Plot_IRF_General.do
	}
